<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>函数节流</title>
    <style>
     body{
         height:2000px;
     }
    </style>
</head>
<body>

<script>
    var flag=1;
    document.body.onscroll=function(){
        if(!flag){
            return ;
        }
        flag=0;
        setTimeout(function(){
            console.log('函数节流');
            flag=1;
        },3000);
    }
</script>
</body>
</html>